package com.fr.funglisoftproduction.flanders.database;

public class Condition
{
	public String _colonne;
	public String GetColonne()
	{
		return _colonne;
	}
	
	public TypeOperator _operator;
	public TypeOperator GetOperator()
	{
		return _operator;
	}
	
	public Object _value;
	public Object GetValue()
	{
		return _value;
	}
	
	public enum TypeOperator
	{
		Equal,
		NotEqual,
		More,
		Less,
		MoreOrEqual,
		LessOrEqual,
		Like,
		NotLike
	}
	
	public Condition(String colonne, TypeOperator operator, Object value)
	{		
		_colonne = colonne;
		_operator = operator;
		_value = value;
	}
	
	@Override
	public String toString()
	{
		String condition = _colonne;
		
		switch (_operator)
		{
			case Equal:
				condition += " = ?";
				break;
			case NotEqual:
				condition += " <> ?";
				break;	
			case More:
				condition += " > ?";
				break;
			case Less:
				condition += " < ?";
				break;
			case MoreOrEqual:
				condition += " >= ?";
				break;
			case LessOrEqual:
				condition += " <= ?";
				break;
			case Like:
				condition += " LIKE ?";
				break;
			case NotLike:
				condition += " NOT LIKE ?";
			default:
				condition += " = ?";
		}
		
		return condition;
	}
}